package modelLayer;
import java.util.ArrayList;

/**
 * Lav en beskrivelse af klassen LoanContainer her.
 * 
 * @author (dit navn her)
 * @version (versions nummer eller dato her)
 */
public class LoanContainer
{
     ArrayList<Loan> loans;
    private static LoanContainer instance;
    /**
     * Constructor for objects of class PersonContainer
     */
    private LoanContainer()
    {
        loans = new ArrayList<Loan>();
    }
    
    public static LoanContainer getInstance()
    {
        if(instance == null)
            instance = new LoanContainer();
        return instance;
    }
    
    public void addLoan(Loan loan)
    {
        loans.add(loan);
    }
    
    public void removeLoan(Loan l)
    {
        loans.remove(l);
    }
    
    public PartLoan getPartLoanWithCopy(Copy copy)
    {
        for(Loan loan : loans)
        {
            for(PartLoan partLoan : loan.getPartLoans())
            {
                if(partLoan.hasCopy(copy))
                {
                    return partLoan;
                }
            }
        }
        return null;
    }
}
